package class7;

import java.util.Scanner;

class School
{
    private String SchoolName;
    private String SchoolType;
    private String Address;
    private String Indroduce;

    public School() {
    }

    public School(String schoolName, String schoolType, String address, String indroduce) {
        SchoolName = schoolName;
        SchoolType = schoolType;
        Address = address;
        Indroduce = indroduce;
    }

    public String getSchoolName() {
        return SchoolName;
    }

    public void setSchoolName(String schoolName) {
        SchoolName = schoolName;
    }

    public String getSchoolType() {
        return SchoolType;
    }

    public void setSchoolType(String schoolType) {
        SchoolType = schoolType;
    }

    public String getAddress() {
        return Address;
    }

    public void setAddress(String address) {
        Address = address;
    }

    public String getIndroduce() {
        return Indroduce;
    }

    public void setIndroduce(String indroduce) {
        Indroduce = indroduce;
    }
}

class SchoolManager
{
    private School[] schools;
    private int count;
    private int capacity;

    public SchoolManager(int capacity) {
        this.capacity = capacity;
        this.schools = new School[capacity];
        this.count = 0;
    }

    public boolean addSchool(School school)
    {
        if(count>=capacity){
            School[] newSchools = new School[capacity*2];
            System.arraycopy(schools, 0, newSchools, 0, capacity);
            schools = newSchools;
            capacity *= 2;
        }
        schools[count++]=school;
        return true;
    }

    public void SearchSchool(String name)
    {
        for(int i=0;i<count;i++)
        {
            School school=schools[i];
            if(school.getSchoolName().equals(name))
            {
                System.out.println("学校名称: " + school.getSchoolName());
                System.out.println("学校类型: " + school.getSchoolType());
                System.out.println("学校地址: " + school.getAddress());
                System.out.println("学校介绍: " + school.getIndroduce());
                return;
            }
        }
        System.out.println("未找到该学校");
    }
    public void printAllSchools()
    {
        for(int i=0;i<count;i++)
        {
            School school=schools[i];
            System.out.println("学校名称: " + school.getSchoolName());
            System.out.println("学校类型: " + school.getSchoolType());
            System.out.println("学校地址: " + school.getAddress());
            System.out.println("学校介绍: " + school.getIndroduce());
            System.out.println("--------------------------------------------------");
        }
    }
}
public class SchoolSystem {
    public static void main(String[] args) {
        SchoolManager schoolManager = new SchoolManager(5);
        schoolManager.addSchool(new School("清华大学", "综合性大学", "北京市海淀区", "中国顶尖学府，培养了众多杰出人才。"));
        schoolManager.addSchool(new School("北京大学", "综合性大学", "北京市海淀区", "中国历史最悠久的大学之一，学术氛围浓厚。"));
        schoolManager.addSchool(new School("复旦大学", "综合性大学", "上海市杨浦区", "中国著名学府，注重创新与实践。"));
        schoolManager.addSchool(new School("上海交通大学", "综合性大学", "上海市闵行区", "工科实力强劲，科研成果丰硕。"));
        schoolManager.addSchool(new School("浙江大学", "综合性大学", "杭州市西湖区", "中国顶尖大学之一，学科门类齐全。"));

        Scanner sc=new Scanner(System.in);
        int input=0;
        do {
            System.out.println("欢迎使用学校信息查询系统！");
            System.out.println("1. 查询学校信息");
            System.out.println("2. 查看所有学校信息");
            System.out.println("0. 退出系统");
            System.out.print("请输入选项: ");
            input = sc.nextInt();
            switch (input) {
                case 1:
                    System.out.print("请输入学校名称: ");
                    String name = sc.next();
                    schoolManager.SearchSchool(name);
                    break;
                case 2:
                    schoolManager.printAllSchools();
                    break;
                case 0:
                    System.out.println("感谢使用学校信息查询系统，再见！");
                    break;
                default:
                    System.out.println("输入无效，请重新输入。");
                    break;
            }
        }while(input!=0);
    }
}
